package com.example.kugou.service.serviceimpl;

import com.example.kugou.mapper.CommentMapper;
import com.example.kugou.pojo.Comment;
import com.example.kugou.service.CommentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@Service("commentService")
public class CommentServiceImpl implements CommentService {
    @Resource
    CommentMapper commentMapper;
    @Override
    public Map<String, Object> getCommentBySingId(int singId) {
        Map<String,Object> commentMap=new LinkedHashMap<>();
        List<Comment> commentBySingId = commentMapper.getCommentBySingId(singId);
        if (commentBySingId!=null){
            commentMap.put("list",commentBySingId);
        }
        return commentMap;
    }

    @Override
    public Map<String, Object> getCommentBySong_sheetId(int song_sheetId) {
        Map<String,Object> commentMap=new LinkedHashMap<>();
        List<Comment> comments = commentMapper.getCommentBySong_sheetId(song_sheetId);
        if (comments!=null){
            commentMap.put("list",comments);
        }
        return commentMap;
    }

    @Override
    public Map<String, Object> insertComment(Comment comment) {
        Map<String,Object> commentMap=new LinkedHashMap<>();
        int i = commentMapper.insertComment(comment);
        commentMap.put("msg","Failed");
        if (i>0){
            commentMap.put("msg","Success");
        }
        return commentMap;
    }
}
